package com.kaifamiao.mapper;

import com.kaifamiao.model.UserModel;
import com.kaifamiao.provider.UserProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author LENOVO
* @description 针对表【user】的数据库操作Mapper
* @createDate 2022-07-21 19:58:48
* @Entity com.kaifamiao.model.User
*/
public interface UserMapper {

//    List<UserModel> selectAll();
//
//    int deleteByPrimaryKey(Long id);
//
//    int insertSelective(UserModel record);
//
//    UserModel selectByPrimaryKey(Long id);
//
//    int updateByPrimaryKeySelective(UserModel record);
//
//    int setlectByUser(UserModel model);


    @SelectProvider(value = UserProvider.class,method = "selectAll")
    List<UserModel> selectAll();

    @Select("select * from user where id=#{id}")
    UserModel selectByPrimaryKey(Long id);

    @InsertProvider(value = UserProvider.class,method ="insertSelective" )
    int insertSelective(UserModel record);

    @UpdateProvider(value = UserProvider.class,method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(UserModel record);

    @Delete("delete from user where id=#{id}")
    int deleteByPrimaryKey(Long id);

    @SelectProvider(UserProvider.class)
    List<UserModel> selectByUser(UserModel model);

    @SelectProvider(UserProvider.class)
    UserModel selectByAccountName(String accountname);

    @Update("update `user` set oid = #{oid} where id = #{id}")
    int addOid(@Param("oid") Integer oid,@Param("id") Integer id);

    @Update("UPDATE `library`.`user` SET `oid` = NULL WHERE `id` = #{id}")
    int setOidNull(Integer id);
}
